package java面向对象.对象类型转化;
//向下转型
public class Text {
    public static void main(String[] args) {
      Animal animal = new Dog();
      Dog dog = (Dog) animal;
      dog.shout();
      dog.eat();
      Animal animal2 = new Dog();
       //instanceof关键字用来判断两个类是否相等
      System.out.println("Dog和Animal是否相同"+(animal2 instanceof Animal));
    }
}
class Animal {
    public void shout() {
        System.out.println("动物叫");
    }
}
class Dog extends Animal {
    public void shout() {
        System.out.println("汪汪汪");
    }
    public void eat() {
        System.out.println("啃骨头");
    }
}
